package com.yunupmall.controller.amdin;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yunupmall.api.fordVO.LogisticsVo;
import com.yunupmall.api.fordentity.Logistics;
import com.yunupmall.service.admin.service.LogisticsService;
import com.yunupmall.uits.Result;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/Logistics")
@AllArgsConstructor
public class LogisticsController {
    private final LogisticsService logisticsService;
    private final Result result;

    @PostMapping("/save")
    public Result<String> save(@RequestBody LogisticsVo logisticsVo){
        try {
            return result.ok(logisticsService.saveData(logisticsVo));
        }catch (Exception e) {
            return result.error(e.getMessage());
        }
    }

    @PostMapping("/page")
    public Result<Page<Logistics>> page(@RequestBody LogisticsVo logisticsVo){
        try {
            return result.ok(logisticsService.pageDate(logisticsVo));
        }catch (Exception e) {
            return result.error(e.getMessage());
        }
    }

    @GetMapping("/del")
    public Result<String> del(Integer id){
        try {
            return result.ok(logisticsService.del(id));
        }catch (Exception e) {
            return result.error(e.getMessage());
        }
    }
    @GetMapping("/getList")
    public Result<List<Logistics>> getList(){
        try {
            return result.ok(logisticsService.getList());
        }catch (Exception e) {
            return result.error(e.getMessage());
        }
    }
}
